package com.zxx.pattern.statePattern.state3.sample;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.zxx.designpattern.R;


//详情界面-用于转发，判断是否是登录状态
//功能：转发、注销
public class MainState3Activity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main_state3);

        //转发
        findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //调用LoginContext的转发函数
                LoginContext.getLoginContext().forward(MainState3Activity.this);
            }
        });

        //注销
        findViewById(R.id.button2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                //设置注销状态
                LoginContext.getLoginContext().setState(new LogoutState());
                Toast.makeText(getApplicationContext(), "注销成功", Toast.LENGTH_SHORT).show();
            }
        });
    }
}